using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GeneralLibs;
using Vouchers;
using Lists;
using ListForms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Columns;
using BasicForms;

namespace QuanLyQuy
{
    public partial class FrmDanhSachPhieuThuClinic : BasicForms.FrmDanhSachChungTu
    {
        public FrmDanhSachPhieuThuClinic()
        {
            InitializeComponent();
            _DieuKienTimKiem.LoaiChungTu = DanhMucLoaiChungTu.Instance.GetByMa("PhieuThu");
            _DieuKienTimKiem.DieuKienKhac = "Clinic_PhieuID IS NOT NULL";
        }

        void frm_RequestAddNew()
        {
            try
            {
                FrmEditPhieuThuClinic frm = new FrmEditPhieuThuClinic(_DanhSachChungTu.CreateNew(_DieuKienTimKiem.LoaiChungTu));
                frm.RequestAddNew += new FrmEditChungTu.OnRequestAddNew(frm_RequestAddNew);
                frm.Show();
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            }
        }

        public override void CreateNew()
        {
            try
            {
                FrmEditPhieuThuClinic frm = new FrmEditPhieuThuClinic(_DanhSachChungTu.CreateNew(_DieuKienTimKiem.LoaiChungTu));
                frm.RequestAddNew += new FrmEditChungTu.OnRequestAddNew(frm_RequestAddNew);
                frm.Show();
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            }
        }
        protected override void Edit()
        {
            try
            {
                foreach (int selectedRow in gridViewDsChungTu.GetSelectedRows())
                {
                    FrmEditPhieuThuClinic frm = new FrmEditPhieuThuClinic(_DanhSachChungTu.GetByDataRow(gridViewDsChungTu.GetDataRow(selectedRow)));
                    frm.RequestAddNew += new FrmEditChungTu.OnRequestAddNew(frm_RequestAddNew);
                    frm.Show();
                }
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            }
        }
    }
}